package quiz;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public abstract class Quiz implements Serializable {
	private static final long serialVersionUID = -3425918671543554244L;
	List<Question> questions;
	private String name;
	public String getName() {
		return name;
	}

	public void addQuestion(Question question) {
		questions.add(question);
	}
	
	public void setName(String name) {
		this.name = name;
	}
	
	public Quiz() {
		questions = new ArrayList<Question>();
	}
	
	public int getQuizMaxPoints() {
		int sum = 0;
		for (Question question : questions) {
			sum += question.getValue();
		}
		return sum;
	}
	public int getNumberOfQuestions() {
		return questions.size();
	}
	
	public abstract String quizName();
	
	public String basicSetupPrint () {
		String returnString = "";
		returnString+= "Quiz: " + this.quizName()+"\n";
		for (int i = 0; i < questions.size(); i++) {
			returnString += (i+1) + " " +questions.get(i).getNicePrintForm()+"\n";
		}
		return returnString;
	}
	
	public String printMasterHelper() {
		String returnString = "";
		for (int i = 0; i < questions.size(); i++) {
			returnString += (i + 1) + " " + questions.get(i).getQuestion() +"\n";
			returnString += "Oppgavens verdi: " + questions.get(i).getValue() + " poeng\n";
			returnString += "Hjelpemiddel: " + questions.get(i).getHelp()+"\n";
			returnString += "\n"+"\n";
		}
		return returnString;
	}
	
	public String printMasterSolutions() {
		String returnString = "";
		for (int i = 0; i < questions.size(); i++) {
			returnString += (i + 1) + " " + questions.get(i).getQuestion()+"\n";
			returnString += "Fasit:" + questions.get(i).getSolution()+"\n";
			returnString += "Oppgavens verdi: " + questions.get(i).getValue() + " poeng"+"\n";
			returnString += "\n\n";
		}
		return returnString;
	}	
}